
#####
# 字典合并，自带了update方法
#####
profile = {"name": "xiaoming", "age": 27}
ext_info = {"gender": "male"}
profile.update(ext_info)
print(profile)
#这样做，会更新数据到自身上，如果不想更新到自身，可以使用deepcopy

from copy import deepcopy
full_profile = deepcopy(profile)
ext_info_2 = {"balance": 25}
full_profile.update(ext_info_2)
print(full_profile)


###########
#先解包再合并字典
# dict(**profile, **ext_info)
# dict((("name", "xiaoming"), ("age", 27), ("gender", "male")))
###########
full_profile01 = {**profile, **ext_info}
print(full_profile01)


#############
##最酷炫的字典解析式
##
###############
full_profile03={k:v for d in [profile, ext_info] for k,v in d.items()}
print(full_profile03)
